<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/jquery-3.2.1.min.js"></script>
  <title>三目变化</title>
  <style>
    body {
      background-color: darkgray;
    }

    .img-bag {
      position: relative;
      left: -110px;
      top: -10px;
    }
  </style>
</head>

<body>
  <div>
    <ul id="bottom">
      <li index="1" class="activeClass">
        <img src="./photo/1/imgnav_init_1.jpg" class="img-cle">
        <img src="./photo/学校概览/Background.png" alt="" class="img-bag">
      </li>
      <li index="2">
        <img src="./photo/1/imgnav_init_1.jpg">
      </li>
      <li index="3">
        <img src="./photo/1/imgnav_init_1.jpg">
      </li>
      <li index="4">
        <img src="./photo/1/imgnav_init_1.jpg">
      </li>
      <li index="5">
        <img src="./photo/1/imgnav_init_1.jpg">
      </li>
    </ul>
  </div>
  <script>
    $('div').on("click", "li", function (event) {
      //事件委托      
      var preindex = $("li.activeClass").attr("index");
      // console.log(preindex);
      //字体变颜色

      $(this).addClass("activeClass").siblings().removeClass("activeClass");

      if (event.target.tagName === 'IMG') {

        var nodes = $('#bottom li img');
        // console.log(nodes);

        for (var i = 0; i < nodes.length; i++) {
          //把所有的路径全部变成未选中的图标
          nodes[i].src = nodes[i].src.replace(/.jpg|_selected.jpg/, '.jpg');
        }

        event.target.src = event.target.src.replace(/.jpg|_selected.jpg/, '_selected.jpg');
      }
    }
    )
  </script>
</body>

</html>